//
//  BaseViewController.m
//  New
//
//  Created by dlios on 15-7-16.
//  Copyright (c) 2015年 yangTao. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
 
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
   
    if ([@"on"isEqualToString:[user objectForKey:@"night"]]) {
        self.view.backgroundColor = [UIColor grayColor];
        self.navigationController.navigationBar.barTintColor = [UIColor grayColor];
        self.tabBarController.tabBar.barTintColor = [UIColor grayColor];    }
    else{
            
            self.view.backgroundColor = [UIColor whiteColor];
            self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
            self.tabBarController.tabBar.barTintColor = [UIColor whiteColor];
            
        }
    
    NSNotificationCenter *notification = [NSNotificationCenter defaultCenter];
    [notification addObserver:self selector:@selector(changeNight:) name:@"changeNight" object:nil];
    
    
    
    
}

-(void)changeNight:(NSNotification *)notification{
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    [user setObject:(NSString *)[notification object] forKey:@"night"];
    
    if ([@"on"isEqualToString:[user objectForKey:@"night"]]) {
        self.view.backgroundColor = [UIColor grayColor];
        self.navigationController.navigationBar.barTintColor = [UIColor grayColor];
        self.tabBarController.tabBar.barTintColor = [UIColor grayColor];    }else{
        
            self.view.backgroundColor = [UIColor whiteColor];
            self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
            self.tabBarController.tabBar.barTintColor = [UIColor whiteColor];
        
        }
    
    

}
-(void)dealloc{

[[NSNotificationCenter defaultCenter] removeObserver:self name:@"changeNight" object:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
